package com.haoliangtian.ui.main;

import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;

import com.haoliangtian.R;

/**
 * 主页ViewPager的每个页面的ViewModel<br>
 * 2020/5/21 2:53 PM
 *
 * @author 华软科技
 * @version 1.0
 */
public class PageViewModel extends ViewModel {

    private MutableLiveData<Integer> mIndex = new MutableLiveData<>();
    private LiveData<String> mText = Transformations.map(mIndex, new Function<Integer, String>() {
        @Override
        public String apply(Integer input) {
            switch (input) {
                case 1:
                    return "工作概览";
                case 2:
                    return "企业管理";
                case 3:
                    return "土地管理";
                case 4:
                    return "粮食订单";
                case 5:
                    return "农机服务";
                case 6:
                    return "农资服务";
                case 7:
                    return "金融服务";
                case 8:
                    return "灌溉服务";
                case 9:
                    return "仓储服务";
                default:
                    return "暂无内容";
            }
        }
    });

    public void setIndex(int index) {
        mIndex.setValue(index);
    }

    public LiveData<String> getText() {
        return mText;
    }
}